FROM registry.cn-hangzhou.aliyuncs.com/sanbing/jcpp-base:latest AS base
WORKDIR /app
COPY . .
RUN mvn -U -B -T 0.8C clean install -DskipTests

#分层
FROM registry.cn-hangzhou.aliyuncs.com/sanbing/openjdk:21-jdk-slim-bullseye AS builder
WORKDIR /app
COPY --from=base /app/target/application.jar application.jar
RUN java -Djarmode=tools -jar application.jar extract --layers --destination extracted

# 执行
FROM registry.cn-hangzhou.aliyuncs.com/sanbing/openjdk:21-jdk-slim-bullseye
WORKDIR /app
COPY --from=builder /app/extracted/dependencies/ ./
COPY --from=builder /app/extracted/spring-boot-loader/ ./
COPY --from=builder /app/extracted/snapshot-dependencies/ ./
COPY --from=builder /app/extracted/application/ ./
COPY --from=base /app/start.sh .

ENV TZ=Asia/Shanghai

RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && apt update

RUN  mkdir -p /app/logs &&  \
    mkdir -p /app/logs/gc &&  \
    chmod 700 -R /app/logs

RUN chmod a+x *.sh && mv start.sh /usr/bin

EXPOSE 8080 8080

CMD ["start.sh"]


